//
//  HBTextViewController.m
//  HBLibary_Example
//
//  Created by Rambo on 2018/6/11.
//  Copyright © 2018年 Rambo. All rights reserved.
//

#import "HBTextViewController.h"
#import <HBLibary/HBLibary.h>

@interface HBTextViewController ()

@end

@implementation HBTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UITextView *textView = [[UITextView alloc] init];
    textView.frame = CGRectMake(0, 100, self.view.frame.size.width, 100);
    textView.backgroundColor = [UIColor greenColor];
    textView.hb_placeholder = @"请输入文字";
    [textView hb_showEndEditToolView];
    textView.hb_maxLength = 100;
    textView.hb_autoInterceptMaxLength = YES;
    textView.showTextCount = YES;
    [self.view addSubview:textView];
    
    
}


- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewChange:) name:UITextViewTextDidChangeNotification object:nil];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

#pragma mark - 通知

- (void)textViewChange:(NSNotification*)notify{
    UITextView *textView = notify.object;
    if (!textView) return;
    NSLog(@"%@",textView.text);
}

@end
